﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Waf.Applications;
using System.Windows.Input;
using HighLandirect.Applications.Views;
using HighLandirect.Domain;
using System;

namespace HighLandirect.Applications.ViewModels
{
    public class ProductListViewModel : ViewModel<IProductListView>
    {
        private readonly IEnumerable<Product> products;
        private readonly ObservableCollection<Product> selectedProducts;
        private Product selectedProduct;
        private ICommand addNewCommand;
        private ICommand removeCommand;

        
        public ProductListViewModel(IProductListView view, IEnumerable<Product> products)
            : base(view)
        {
            if (products == null) { throw new ArgumentNullException("products"); }
            
            this.products = products;
            this.selectedProducts = new ObservableCollection<Product>();
        }


        public IEnumerable<Product> Products { get { return products; } }

        public ObservableCollection<Product> SelectedProducts
        {
            get { return selectedProducts; }
        }

        public Product SelectedProduct
        {
            get { return selectedProduct; }
            set
            {
                if (selectedProduct != value)
                {
                    selectedProduct = value;
                    RaisePropertyChanged("SelectedProduct");
                }
            }
        }

        public ICommand AddNewCommand
        {
            get { return addNewCommand; }
            set
            {
                if (addNewCommand != value)
                {
                    addNewCommand = value;
                    RaisePropertyChanged("AddNewCommand");
                }
            }
        }

        public ICommand RemoveCommand
        {
            get { return removeCommand; }
            set
            {
                if (removeCommand != value)
                {
                    removeCommand = value;
                    RaisePropertyChanged("RemoveCommand");
                }
            }
        }
    }
}
